<?php
/**
 * Created by PhpStorm.
 * @author: 汤文辉
 * @since: 2017/6/18 19:02
 * @revised: 刘世杰 2017-6-20 23:14:14
 */
    date_default_timezone_set('prc');
    include ("../config/mysqlconfig.php");
    include("../class/Comment.php");

    $book_id = intval($_GET['book_id']);
    $text = $_GET["text"];
    $time = time();
    $time = date("Y-m-d",$time);
    $user_id = $_COOKIE["user_login"];
//
    $com = new Comment();
    if (!isset($user_id)){
        echo 2;   //登陆后发表评论
    }else {
        $state = $com->Remark($book_id, $text, $time, $user_id);
        if ($state == 1) {
            echo 1;  //"<script>alert('评论成功!');</script>";
        } else if ($state == 0) {
            echo 0;  //"<script>alert('评论失败!');</script>";
        } else {
            echo 3;  //"<script>alert('评论不得为空!');</script>";
        }
    }


